#!/usr/bin/env python
# encoding: utf-8
"""
@author: youfeng
@email: youfeng243@163.com
@license: Apache Licence
@file: pyv8_demo.py
@time: 2017/12/28 11:20
"""

from pyv8 import PyV8

ctxt = PyV8.JSContext()

ctxt.enter()

func = ctxt.eval('''
var l = function() {
    while (window._phantom || window.__phantomas) {};
    var cd, dc = '__jsl_clearance=1514430130.595|0|';
    cd = (function() {
        var x = [0],
            i,
            c,
            t = '',
            chars = 'JgSe0upZ%rOm9XFMtA3QKV7nYsPGT4lifyWwkq5vcjH2IdxUoCbhERLaz81DNB6',
            f = function(c) {
                for (var i = 0; i < 8; i++) c = (c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1);
                return c
            };
        while (t = x.join().replace(new RegExp('\\d+', 'g'),
            function(d) {
                return chars.charAt(d)
            }).split(',').join('') + '6FSORc2HZ0%2BS%2FWGASDfgLSso%3D') {
            c = -1;
            for (i = 0; i < t.length; i++) c = (c >>> 8) ^ f((c ^ t.charCodeAt(i)) & 0xFF);
            if (2905504599 === (c ^ ( - 1)) >>> 0) return t;
            i = 0;
            while (++x[i] === chars.length) {
                x[i++] = 0;
                if (i === x.length) x[i] = -1
            }
        }
    })();
    dc += cd;
    setTimeout('location.href=location.href.replace(/[\?|&]captcha-challenge/,\'\')', 1500);
    document.cookie = (dc + ';Expires=Thu, 28-Dec-17 04:02:10 GMT;Path=/;');
};
if ((function() {
        try {
            return !! window.addEventListener;
        } catch(e) {
            return false;
        }
    })()) {
    document.addEventListener('DOMContentLoaded', l, false);
} else {
    document.attachEvent('onreadystatechange', l);
}
''')

print func